package com.itheima.threadDemo;

public class Demo4 {
    public static void main(String[] args) throws InterruptedException {
        System.out.println("前");
        Thread.sleep(1000);
        System.out.println("后");
        //创建对象
      MyRunable mr = new MyRunable();
        //设置名称
        Thread t1 = new Thread(mr);
        Thread t2 = new Thread(mr);
        t1.setName("小明");
        //调试方法
        t1.start();
        t2.start();
    }
}
class MyRunable implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 50; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"启动了"+i);
        }
    }
}